import xlrd
# 获取邀请函模板内容，并存于invitation_template变量中
with open('通知模板.txt', 'r') as fr:
    invitation_template = fr.read()

book = xlrd.open_workbook('获奖汇总.xlsx')
stu = book.sheet_by_index(0)
for rx in range(stu.nrows): # 遍历工作表的有效行数
    name = stu.cell_value(rowx=rx, colx=0) # 读取姓名
    award = stu.cell_value(rowx=rx, colx=1) # 读取获奖情况
    email = stu.cell_value(rowx=rx, colx=2) # 读取email
    print('name: {}; award: {}; Email: {}'.format(name, award, email))
    invitation_temp = invitation_template.replace('[[[name]]]', name)
    invitation = invitation_temp.replace('[[[award]]]', award)
with open('通知模板(修改).txt', 'w') as fr:
    invitation_template = fr.write()